# import ddddocr
# import cv2
#
# det = ddddocr.DdddOcr(det=True, show_ad=False)
#
#
# with open("static/source2.jpg", 'rb') as f:
#     image_bytes = f.read()
#
# bboxes = det.detection(image_bytes)
# print(bboxes)
#
# im = cv2.imread("static/source2.jpg")
#
# for bbox in bboxes:
#     x1, y1, x2, y2 = bbox
#     im = cv2.rectangle(im, (x1, y1), (x2, y2), color=(0, 0, 255), thickness=2)
# cv2.imwrite("./static/source2_rect.jpg", im)





# 滑动
# import ddddocr
# import cv2
#
# det = ddddocr.DdddOcr(det=False, ocr=False, show_ad=False)
#
# with open('./static/slide/target.png', 'rb') as f:
#     target_bytes = f.read()
#
# with open('./static/slide/background.png', 'rb') as f:
#     background_bytes = f.read()
#
# res = det.slide_match(target_bytes, background_bytes)
#
# print(res['target'])
#
# im = cv2.imread("./static/slide/background.png")
# im = cv2.rectangle(im, (res['target'][0], res['target'][1]), (res['target'][2], res['target'][3]), color=(0, 0, 255), thickness=2)
# cv2.imwrite("./static/slide/background_rect.png", im)


import ddddocr
slide = ddddocr.DdddOcr(det=False, ocr=False)

with open('./static/slide/target3.jpg', 'rb') as f:
    target_bytes = f.read()

with open('./static/slide/background3.jpg', 'rb') as f:
    background_bytes = f.read()

# img = cv2.imread("bg.jpg")

res = slide.slide_comparison(target_bytes, background_bytes)

print(res)